package main
import(
	"fmt"
	"net/http"
	"text/template"
)

func main(){
	http.HandleFunc("/", index)
	http.HandleFunc("/sum", sum)
	fmt.Println("Listen And Serve ...")
	http.ListenAndServe(":8000", nil)
}

func index(writer http.ResponseWriter, request *http.Request){
	f, err := template.ParseFiles("./form.html")
	
	t := template.Must(f, err)
	
	t.Execute(writer, nil)
}

func sum(writer http.ResponseWriter, request *http.Request){
	request.ParseForm()
	
	fmt.Fprintln(writer, request.Form)
	
	fmt.Fprintln(writer, request.Form["number1"][0])
	fmt.Fprintln(writer, request.Form["number2"][0])
}
